#ifndef FRAMEBUF_H
#define FRAMEBUF_H

#include <etherfabric/ef_vi.h>

#include "common_defs.h"
#include "link_node.h"

namespace usnet {
enum CtrlFlag {
    FB_REUSE = 1,
};

enum FlagMask : uint32_t {
    FB_USER_MASK = 0xf0000000,
    FB_TRAN_MASK = 0x0ff00000,
    FB_INET_MASK = 0x000ffff0,
    FB_CTRL_MASK = 0x0000000f,
};

enum FlagShift {
    FB_CTRL_SHIFT = 0,
    FB_INET_SHIFT = 4,
    FB_TRAN_SHIFT = 20,
    FB_USER_SHIFT = 28,
};

struct FrameBuf {
    uint32_t    id_;
    uint32_t    flags_;
    uint32_t    tsp_pdu_;   // transportation PDU size
    EthHeader*  eth_hdr_;
    union {
        IP4Header*  ip4_hdr_;
        IP6Header*  ip6_hdr_;
        ARPHeader*  arp_hdr_;
    } inet_hdr_;
    union {
        TCPHeader*  tcp_hdr_;
        UDPHeader*  udp_hdr_;
    } tran_hdr_;
    LinkNode    link_;
    ef_addr     dma_addr_;
    uint8_t     mem_addr_[1] EF_VI_ALIGN(EF_VI_DMA_ALIGN); 
};
} // end of namespace usnet
#endif